package jcolibri.test.recomendador.presentacion;


import java.awt.BorderLayout;

import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;

import java.awt.GridBagLayout;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.Toolkit;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import jcolibri.test.recomendador.datos.User;



	public class ElegirPerfiles extends JFrame {

		private static final long serialVersionUID = 1L;

		private JButton jButton1 = null;
		private Color c=(new JComboBox()).getBackground();
		private JComboBox sexoBox=null;
		private JLabel sexo=null;

		private JTextField edadText=null;
		private JLabel edad=null;

		private JTextField cpText=null;
		private JLabel cp=null;
	
		private JComboBox profBox=null;
		private JLabel prof=null;
		private User.Occupation[] profesiones=User.Occupation.values();

		static ElegirPerfiles vl;
		
		public static ElegirPerfiles getInstancia(){
			if (vl==null)
				vl=new ElegirPerfiles();
			return vl;
		}

		public static ElegirPerfiles getInstanciaVisible(){
			if (vl==null)
				vl=new ElegirPerfiles();
			vl.setVisible(true);
		    vl.pack();
		    vl.initialize();
			return vl;
		}

		
		private JPanel contenedor = null;

		/**
		 * This is the default constructor
		 */
		public ElegirPerfiles() {
			super();
			initialize();
			jcolibri.method.gui.utils.WindowUtils.centerWindow(this);
		}

		/**
		 * This method initializes this
		 * 
		 * @return void
		 */
		private void initialize() {
			this.setSize(260, 230);
			this.setContentPane(getContenedor());
			this.setResizable(false);
			this.setName("marco");
			this.setTitle("ElegirPerfiles de usuario");
			this.setVisible(true);
			this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		}

	
		/**
		 * This method initializes jButton1	
		 * 	
		 * @return javax.swing.JButton	
		 */
		private JButton getJButton1() {
//			if (jButton1 == null) {
				jButton1 = new JButton();
				jButton1.setText("Aceptar");
				jButton1.addActionListener(new oyenteElegirPerfiles());
				jButton1.setBounds(new Rectangle(80, 160, 90, 25));
//			}
			return jButton1;
		}
		
		class oyenteElegirPerfiles implements ActionListener {
	    	
	        public void actionPerformed(ActionEvent a) {
	        	ElegirPerfiles.getInstancia().dispose();
	       }
	}
		

		
		private JComboBox getSexoBox() {
//			if ( sexoBox== null) {
				String [] sexos={"Masculino","Femenino"};
				sexoBox = new JComboBox(sexos);
				sexoBox.setBounds(new Rectangle(100, 10, 130, 25));
				sexoBox.getSelectedObjects();
				c=sexoBox.getBackground();
				ComboBoxModel m=sexoBox.getModel();
//			}
			return sexoBox;
		}
		
		private JLabel getSexo() {
//			if (sexo == null) {
				sexo = new JLabel ("   Sexo : ");
				sexo.setOpaque(true);
				sexo.setBackground(c);
				sexo.setBounds(new Rectangle(5, 10, 80, 25));
//			}
			return sexo;
		}
		
		
		
		private JTextField getEdadText() {
//			if ( edadText== null) {
				edadText = new JTextField (10);
				edadText.setBounds(new Rectangle(100, 40, 130, 25));
				edadText.setBackground(c);
//			}
			return edadText;
		}
		
		private JLabel getEdad() {
//			if (edad == null) {
				edad = new JLabel ("   Edad , entre: ");
				edad.setOpaque(true);
				edad.setBackground(c);
				edad.setBounds(new Rectangle(5, 40, 100, 25));
//			}
			return edad;
		}

		private JTextField getCPText() {
//			if ( cpText== null) {
				cpText = new JTextField (10);
				cpText.setBounds(new Rectangle(100, 70, 130, 25));
				cpText.setBackground(c);
//			}
			return cpText;
		}
		
		private JLabel getCP() {
//			if (cp == null) {
				cp = new JLabel ("                     y: ");
				cp.setOpaque(true);
				cp.setBackground(c);
				cp.setBounds(new Rectangle(5, 70, 100, 25));
//			}
			return cp;
		}

		private JComboBox getProfBox() {
//			if ( profBox== null) {
//				String[] profesiones={"none",
//						"administrator",
//						"artist",
//						"doctor",
//						"educator",
//						"engineer",
//						"entertainment",
//						"executive",
//						"healthcare",
//						"homemaker",
//						"lawyer",
//						"librarian",
//						"marketing",
//						"programmer",
//						"retired",
//						"salesman",
//						"scientist",
//						"student",
//						"technician",
//						"writer",
//						"other",};
				profBox = new JComboBox(profesiones);
				profBox.setSelectedIndex(0);
				profBox.setBounds(new Rectangle(100, 100, 130, 25));
//			}
			return profBox;
		}
		
		private JLabel getProf() {
//			if (prof == null) {
				prof = new JLabel ("   Profesion : ");
				prof.setOpaque(true);
				prof.setBackground(c);
				prof.setBounds(new Rectangle(5, 100, 80, 25));
//			}
		return prof;
		}

		
		
		/**
		 * This method initializes contenedor	
		 * 	
		 * @return ElegirPerfiles.Contenedor	
		 */
		private JPanel getContenedor() {
			if (contenedor == null) {
				contenedor = new JPanel();
				contenedor.setLayout(null);
				contenedor.setPreferredSize(new Dimension(200, 354));
				contenedor.setMaximumSize(new Dimension(200, 354));
				contenedor.setMinimumSize(new Dimension(200, 354));
				contenedor.add(getSexo(),null);
				contenedor.add(getSexoBox(),null);
				contenedor.add(getEdad(),null);
				contenedor.add(getEdadText(),null);
				contenedor.add(getCP(),null);
				contenedor.add(getCPText(),null);
				contenedor.add(getProf(),null);
				contenedor.add(getProfBox(),null);
				contenedor.add(getJButton1(), null);
			}
			return contenedor;
		}
		

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			
			new ElegirPerfiles();
		
		}

	}
